window.onload=function(){
  var menu=document.getElementById("nav").getElementsByClassName("menu");
  for(i=0;i<menu.length;i++){
    //鼠标移到导航条菜单项上时显示二级菜单并设置一级菜单项和二级菜单的样式
	  menu[i].onmouseover=function(){
			this.style.background="#fff";
			var lis=this.getElementsByTagName("ul")[0].getElementsByTagName("li");
			this.getElementsByTagName("ul")[0].style.display="block"; //显示二级菜单
			this.getElementsByTagName("ul")[0].style.width="98px"; //设置二级菜单宽度
						//绝对定位二级菜单
			this.getElementsByTagName("ul")[0].style.position="absolute"; 	      
      for(var i=0;i<lis.length;i++){
				lis[i].onmouseover=function(){//鼠标移到二级菜单项上时背景颜色修改为#999
					this.style.background="#999"; 	
				};
				lis[i].onmouseout=function(){//鼠标移出二级菜单项上时背景颜色修改为白色
					this.style.background="#fff";
				};
		  }
	  };
    //鼠标移出导航条菜单项上时隐藏二级菜单，并修改一级菜单项的背景颜色
	  menu[i].onmouseout=function(){
			this.style.background="#999";
			this.getElementsByTagName("ul")[0].style.display="none";
	  };
  }
};  